<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page import="java.util.*" %>

<jsp:useBean id="addBill" class="se2.BillingPlan" scope="request"/>
<jsp:setProperty name="addBill" property="*"/>

<%
	// -----------------------------------------------------
	// Parses the comma-delimited string of discount IDs and
	// stores it in the BillingPlan object
	// -----------------------------------------------------
	if (addBill.loadDiscounts (request.getParameter("listOfDiscountIds")))
	{
	}
	else
	{
		System.out.println("Fail in loading DiscountPlan.");
%>
		<jsp:forward page="error.jsp?url=addBillingPlan.jsp" />
<%
	}
	
	// -----------------------------------------------------
	// If the BillingPlan was successfully added, forward to
	// view all BillingPlans page
	// -----------------------------------------------------
	if (addBill.addBillingPlan ())
	{
%>
		<jsp:forward page="viewBillingPlan.jsp" />
<%
	}
	
	// -----------------------------------------------------
	// Else, fail to the generic error page
	// -----------------------------------------------------
	else
	{
		System.out.println("Fail in creating BillingPlan.");
%>
		<jsp:forward page="error.jsp?url=addBillingPlan.jsp" />
<%
	}	
%>

